#include "globalvar.h"
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<errno.h>
#include<sys/wait.h>
#include<signal.h>
#include<sys/types.h>
#include<sys/ioctl.h>
#include<unistd.h>
#include<termios.h>
#define MAX_LINE_SIZE 3000

void shell(char* command,char* writeAt,char** writeOverAt)
{
    fp = popen(command, "r");
    if (fp == NULL){
        fprintf(stderr, "popen failed (%s)", strerror(errno));
        return;        
    }
    *writeOverAt=writeAt;
    while (fgets(*writeOverAt, MAX_LINE_SIZE,fp) != NULL){
     	*writeOverAt+=strlen(*writeOverAt);
    }
    
    int ret = pclose(fp);
    if (ret == 127){
        fprintf(stderr, "bad command :%s \n",command);
        return;
    }else if (ret == -1){
        fprintf(stderr, "failed to get child status :%s \n",strerror(errno));
        return;
    }
}